package view;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import model.FileParser;
import model.Manuscript;

/**
 * Class to delete a paper.
 * @author Sarah George
 * @version Autumn 2012
 */
@SuppressWarnings("serial")
public class DeletePaperAction extends AbstractAction {
	
	/**
	 * Field to hold the FileParser.
	 */
	private FileParser fp;
	
	/**
	 * The manuscript to be deleted.
	 */
	private Manuscript paper;
	
	/**
	 * Constructor for DeletePaperAction.
	 * @param the_parser the FileParser
	 * @param the_paper the paper to be deleted.
	 */
	public DeletePaperAction(FileParser the_parser, Manuscript the_paper) {
		super("Unsubmint/Delete Paper");
	    putValue(Action.MNEMONIC_KEY, KeyEvent.VK_D);
	    putValue(Action.SELECTED_KEY, true);
		fp = the_parser;
		paper = the_paper;
	}

	/**
	 * Method to delete a paper.
	 * @param e the action event that triggers this method.
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		fp.removeManuscript(paper);
	}
}//End class delete paper action.